///\todo upgrade

//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2012 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#ifndef _BUOLA_CV_POINTS_H_
#define _BUOLA_CV_POINTS_H_

#include <buola/image/data.h>

namespace buola { namespace cvi {

template<typename tPixelFormat,typename tScalar=float>
struct CCloudPoint
{
    typedef img::CPixel<tPixelFormat> TPixel;
    typedef tScalar TScalar;
    typedef mat::CVec<tScalar,3> TVec;
    
    static const img::EImageFormat mImageFormatID=img::EImageFormat(tPixelFormat::mID+std::is_same<TScalar,float>::value?
                                                                                    img::FORMAT_POINT_FLOAT_OFFSET:
                                                                                    img::FORMAT_POINT_DOUBLE_OFFSET);
    
    CCloudPoint()=default;
    CCloudPoint(const TVec &pPoint,const TPixel &pPixel)
        :   mPoint(pPoint)
        ,   mPixel(pPixel)
    {}
    
    TVec mPoint;
    TPixel mPixel;
};

template<typename tScalar>
struct CCloudPoint<UUnused,tScalar>
{
    typedef tScalar TScalar;
    typedef mat::CVec<tScalar,3> TVec;
    
    static const img::EImageFormat mImageFormatID=std::is_same<TScalar,float>::value?
                                                    img::FORMAT_POINT_FLOAT_OFFSET:
                                                    img::FORMAT_POINT_DOUBLE_OFFSET;
    
    CCloudPoint()=default;
    CCloudPoint(const TVec &pPoint)
        :   mPoint(pPoint)
    {}
    
    TVec mPoint;
};

template<typename tPixelFormat,typename tScalar=float>
struct CCloudPoint_n : public CCloudPoint<tPixelFormat,tScalar>
{
    typedef CCloudPoint<tPixelFormat,tScalar> TBase;
    using typename TBase::TVec;
    using typename TBase::TScalar;
    using typename TBase::TPixel;
    
    static const img::EImageFormat mImageFormatID=img::EImageFormat(tPixelFormat::mID+std::is_same<TScalar,float>::value?
                                                                                    img::FORMAT_POINT_NORMAL_FLOAT_OFFSET:
                                                                                    img::FORMAT_POINT_NORMAL_DOUBLE_OFFSET);
    
    CCloudPoint_n()=default;
    CCloudPoint_n(const TVec &pPoint,const TVec &pNormal,const TPixel &pPixel)
        :   TBase(pPoint,pPixel)
        ,   mNormal(pNormal)
    {}
    
    TVec mNormal;
};

typedef CCloudPoint<img::TFormat_rgb8> CCloudPoint_rgb8;
typedef CCloudPoint<UUnused> CCloudPoint_f;
typedef CCloudPoint_n<img::TFormat_rgb8> CCloudPoint_n_rgb8;
typedef CCloudPoint_n<UUnused> CCloudPoint_n_f;
    
DECLARE_DATA_IMAGE_TYPES(point_rgb8,CCloudPoint_rgb8);
    
/*namespace cvi*/ } /*namespace buola*/ }

#endif
